<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>投票中心</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <!--<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">-->
    <link rel="stylesheet" href="__STATIC__/style/weui.min.css">
    <link rel="stylesheet" href="__STATIC__/style/cmgd.css">
    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="/static/admin/js/layer/layer.js"></script>
    <script src="/static/admin/js/laypage/laypage.js"></script>
    <script src="/static/admin/js/laytpl/laytpl.js"></script>

    <!--奥森图标-->
    <link rel="stylesheet" href="__STATIC__/style/FontAwesome_4.2.0/css/font-awesome.min.css">
    <style>
        .text{padding-left:9px; }
        .placeholder{text-align: center;}
        .fl{text-align: left;}
        .black{color:#000; font-weight: 600;font-size:17px; line-height: 1.8;}
        .color1{color:#30ab88;}
        .color2{color:#1aafe7;}
        .color3{color:#ffc242;}
        .edit{font-size:13px;color:#999;padding-left: 20px;}
        .color4{color:#eb6877;}
        .weui-cell__bd p i{padding: 0 10px 0 2px; font-size: 20px;}
        .weui-cell__bd p{font-size:16px;}
    </style>
</head>
<body>


<!--顶部搜索-->
<div class="page home js_show">

    <!--选择导航-->
    <div class="page__bd ">
        <div class="weui-flex">
            <div class="weui-flex__item"><div class="placeholder" style="font-size: 18px;">{$vote.title}</div></div>
        </div>

        <div class="weui-flex">
            <div class="weui-flex__item"><div class="placeholder" style="text-align: left;font-size: 14px;">{$vote.addtime1}&nbsp;&nbsp;&nbsp;&nbsp;{$vote.instit_name}</div></div>
        </div>

        <div style="padding: 0 12px 20px 12px;">
            {$vote.content}
        </div>

        <div class="weui-flex">
            <div class="weui-flex__item"><div class="placeholder" style="padding-top: 10px;border-top:1px #000 solid;font-size: 18px;">投票列表</div></div>
        </div>

        <div>

            {if condition="$imgs==1"}
                {foreach name='choose' item='v'}
                    <div style="width: 33%;float: left; text-align: center;font-size: 12px; padding-bottom: 15px;" >
                    <img src="/uploads/images/{$v.img}" style="width: 70%; border-radius:50%;  ">
                    <p>{$v.num}票</p>
                    <p style="line-height: 19px;vertical-align: middle;"><input type="checkbox" name="data[choose]" value="{$v.id}"><span style="position: relative;top: -2px;">{$v.choose}{$v.desc}</span></p>
                    </div>
                {/foreach}

            {/if}


            {if condition="$imgs==0"}
                <div class="weui-flex" style="padding: 5px 12px;">
                    <div><div class="placeholder" ><input type="checkbox" name="choose" style="position: relative;top: 1px;"></div></div>
                    <div class="weui-flex__item"><div class="placeholder" style="text-align: left;padding-left: 5px;">A：图1</div></div>
                    <div><div class="placeholder">1000000票</div></div>
                </div>
            {/if}


            <div style="padding: 20px 50px;clear: both;"><a href="javascript:;" id="smt" class="weui-btn weui-btn_primary"> 提交投票</a></div>

        </div>



    </div>

</div>
</body>
<script type="text/javascript">
    $('#smt').click(

            function(){
                var aa = ',';
                bb = 0;
                $("input[name='data[choose]']:checkbox:checked").each(function(){
                    aa+=$(this).val()+',';
                    bb = bb+1;

                });

                console.log(aa);
                console.log(bb);

                cc= '{$vote.max_num}';
                if(bb>cc){
                    layer.msg('每次投票最多选'+cc+'项',{icon:5,time:1000,shade: 0.1,});
                    return false;
                }
                if(aa==','){
                    layer.msg('请勾选你想要投票的选项',{icon:5,time:1000,shade: 0.1,});
                    return false;
                }


                var id = '{$vote.id}';
                $.post('{:url("usercenter/real_vote")}',
                        {id:id,choose:aa},
                        function(data){
                            if(data.code==1) {
                                layer.msg(data.msg,{icon:6,time:1000,shade: 0.1,});
                            }else{
                                layer.msg(data.msg,{icon:5,time:1000,shade: 0.1,});
                            }
                        });



            }



    );

</script>


</html>